package servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.struts.ContextLoaderPlugIn;

import util.ApplicationContextUtil;

public class InitApplicationContextServlet extends HttpServlet {
	
	private static final Log logger = LogFactory.getLog(InitApplicationContextServlet.class);

	public InitApplicationContextServlet() {
		super();
	}

	public void init() throws ServletException {
		logger.info("get applicationContext start");
		ApplicationContextUtil.applicationContext = (WebApplicationContext) getServletContext().getAttribute(
				(new StringBuilder("")).append(ContextLoaderPlugIn.SERVLET_CONTEXT_PREFIX).toString());
		logger.info("get applicationContext end and the value is "+ApplicationContextUtil.applicationContext);
	}

}
